package com.victor.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.victor.dao.InfomationArticleDao;
import com.victor.dao.InfomationDao;
import com.victor.dao.InfomationPhotoDao;
import com.victor.entity.Infomation;
import com.victor.entity.InfomationArticle;
import com.victor.entity.InfomationPhoto;
import com.victor.service.InfomationService;
import com.victor.utils.Msg;

@Service
public class InfomationServiceImpl implements InfomationService {
	@Autowired
	private InfomationDao infomationDao;
	
	@Autowired
	private InfomationArticleDao infomationaticleDao;
	
	@Autowired
	private InfomationPhotoDao infomationPhotoDao;

	@Override
	public boolean insert(Infomation infomation) {
		return infomationDao.insertSelective(infomation);
	}

	@Override
	public boolean inserArticle(InfomationArticle infomationArticle) {
		return infomationaticleDao.insertSelective(infomationArticle);
	}

	@Override
	public boolean insertPhoto(InfomationPhoto infomationPhoto) {
		return infomationPhotoDao.insertSelective(infomationPhoto);
	}

	@Override
	public boolean updateInfomation(Infomation infomation) {
		return infomationDao.updateByPrimaryKeySelective(infomation);
	}

	@Override
	public boolean updateArticle(InfomationArticle infomationArticle) {
		return infomationaticleDao.updateByPrimaryKeySelective(infomationArticle);
	}

	@Override
	public boolean updatePhoto(InfomationPhoto infomationPhoto) {
		return infomationPhotoDao.updateByPrimaryKeySelective(infomationPhoto);
	}

	@Override
	public boolean delInfomation(int[] ids) {
		return infomationDao.deleteByPrimaryKey(ids);
	}

	@Override
	public List<InfomationPhoto> selPhotoByInfoId(int i) {
		return infomationPhotoDao.selByInfoId(i);
	}

	@Override
	public boolean delArticle(int[] ids) {
		return infomationaticleDao.deleteByPrimaryKey(ids);
	}

	@Override
	public boolean delPhoto(int[] ids) {
		return infomationPhotoDao.deleteByPrimaryKey(ids);
	}

	@Override
	public InfomationPhoto selPhotoById(int i) {
		return infomationPhotoDao.selById(i);
	}

	@Override
	public PageInfo<Infomation> selAll(int page, int row) {
		PageHelper.startPage(page, row);
		List<Infomation> list = infomationDao.selAll();
		return new PageInfo<>(list, 5);
	}

	@Override
	public List<Infomation> selAllNoPage() {
		return infomationDao.selAll();
	}

	@Override
	public Infomation selInfomationXiangqing(Infomation infomation) {
		return infomationDao.selXiangqing(infomation);
	}

	@Override
	public PageInfo<Infomation> selBySearch(String search,int page,int row) {
		PageHelper.startPage(page, row);
		List<Infomation> list = infomationDao.selBySearch(search);
		return new PageInfo<>(list, 5);
	}

	@Override
	public PageInfo<Infomation> selBytime(String start, String end,int page,int row) {
		PageHelper.startPage(page, row);
		List<Infomation> list = infomationDao.selByTime(start,end);
		return new PageInfo<>(list, 5);
	}

}
